public final class SpotAnimation {
	public static Cache gfxCache = new Cache(30);
	public static SpotAnimation cache[];
	public Animation aAnimation_407;
	private int anInt404;
	private int anInt405;
	private int anInt406;
	public int anInt410;
	public int anInt411;
	public int anInt412;
	public int anInt413;
	public int anInt414;
	private int[] anIntArray408;
	private int[] anIntArray409;

	public static void unpackConfig(Archive archive) {
		Packet buffer = new Packet(archive.getFile("spotanim.dat"));
		int length = buffer.getUnsignedShort();
		if (SpotAnimation.cache == null) {
			SpotAnimation.cache = new SpotAnimation[length];
		}
		for (int j = 0; j < length; j++) {
			if (SpotAnimation.cache[j] == null) {
				SpotAnimation.cache[j] = new SpotAnimation();
			}
			SpotAnimation.cache[j].anInt404 = j;
			SpotAnimation.cache[j].readValues(buffer);
		}
	}

	public Model getModel() {
		Model model = (Model) SpotAnimation.gfxCache.get(anInt404);
		if (model != null) {
			return model;
		}
		model = Model.method462(anInt405);
		if (model == null) {
			return null;
		}
		for (int i = 0; i < 6; i++) {
			if (anIntArray408[0] != 0) {
				model.method476(anIntArray408[i], anIntArray409[i]);
			}
		}
		SpotAnimation.gfxCache.put(model, anInt404);
		return model;
	}

	private void readValues(Packet buffer) {
		do {
			int i = buffer.getUnsignedByte();
			if (i == 0) {
				return;
			}
			if (i == 1) {
				anInt405 = buffer.getUnsignedShort();
			} else if (i == 2) {
				anInt406 = buffer.getUnsignedShort();
				if (Animation.animations != null) {
					aAnimation_407 = Animation.animations[anInt406];
				}
			} else if (i == 4) {
				anInt410 = buffer.getUnsignedShort();
			} else if (i == 5) {
				anInt411 = buffer.getUnsignedShort();
			} else if (i == 6) {
				anInt412 = buffer.getUnsignedShort();
			} else if (i == 7) {
				anInt413 = buffer.getUnsignedByte();
			} else if (i == 8) {
				anInt414 = buffer.getUnsignedByte();
			} else if ((i >= 40) && (i < 50)) {
				anIntArray408[i - 40] = buffer.getUnsignedShort();
			} else if ((i >= 50) && (i < 60)) {
				anIntArray409[i - 50] = buffer.getUnsignedShort();
			} else {
				System.out.println("Error unrecognised spotanim config code: " + i);
			}
		} while (true);
	}

	private SpotAnimation() {
		anInt406 = -1;
		anIntArray408 = new int[6];
		anIntArray409 = new int[6];
		anInt410 = 128;
		anInt411 = 128;
	}
}
